// Package main provides ...
package main

import "fmt"

func main() {
	a, b := 10, 20
	swap1(a, b) //值传递，实参将自己的值拷贝一份，给形参

	fmt.Printf("main :a=%d,b=%d\n", a, b) //main :a=10,b=20

	c, d := 10, 20
	swap2(&c, &d) //值传递，实参将自己的值(地址值)拷贝一份，给形参

	fmt.Printf("main :c=%d,d=%d\n", c, d) //main :c=20,d=10
}

func swap1(a, b int) {
	a, b = b, a

	fmt.Printf("swap1:a=%d,b=%d\n", a, b) //swap1:a=20,b=10
}

func swap2(c, d *int) {
	*c, *d = *d, *c //等号左边的*c，*d 代表空间内存，等号右边的 *c,*d代表内容(值)

	fmt.Printf("swap2:*c=%d,*d=%d\n", *c, *d) //swap2:*c=20,*d=10
}
